import { useFetchGet, useFetchPost } from '~/composables/useHttp/useFetch'
import { useFetchRefGet, useFetchRefPost } from '~/composables/useHttp/useFetchRef'

/**
 * 文章列表
 */
export const articlesApi = (p = 1) => {
    return useFetchRefPost<ArticleVo>('articlesApi', '/article/list', {
        body: { pageNum: p }
    })
}
/**
 * 分类文章列表
 */
export const articleMenuApi = (p = 1, menuId: string) => {
    return useFetchRefPost<ArticleVo>('articleMenuApi', '/article/list', {
        body: { pageNum: p, menuId: menuId }
    })
}
/**
 * 标签筛选文章列表
 */
export const articleTagsApi = (tagIds: string[], p = 1) => {
    return useFetchRefPost<ArticleVo>('articleTagsApi', '/article/articleTags', {
        body: { tagIds: tagIds, pageNum: p }
    })
}
/**
 * 置顶列表
 */
export const articleTopsApi = (p = 1) => {
    return useFetchRefPost<ArticleVo>('articleTopsApi', '/article/list', {
        body: { isTop: 1, pageNum: p }
    })
}
/**
 * 视频列表
 */
export const articleVideoApi = (p = 1) => {
    return useFetchRefPost<ArticleVo>('articleVideoApi', '/article/list', {
        body: { type: 2, pageNum: p }
    })
}
/**
 * 音乐列表
 */
export const articleMusicApi = (p = 1) => {
    return useFetchRefPost<ArticleVo>('articleMusicApi', '/article/list', {
        body: { type: 4, pageNum: p }
    })
}
/**
 * 图集列表
 */
export const articleImgsApi = (p = 1) => {
    return useFetchRefPost<ArticleVo>('articleImgsApi', '/article/list', {
        body: { type: 3, pageNum: p }
    })
}
/**
 * 热门文章列表
 */
export const articleHotsApi = (p = 1) => {
    return useFetchRefPost<ArticleVo>('articleHotsApi', '/article/articleHots', {
        body: { pageNum: p }
    })
}
/**
 * 随机文章列表
 */
export const articleRandomsApi = () => {
    return useFetchRefGet<ArticleVo>('articleRandomsApi', '/article/articleRandoms')
}
/*
 * 文章搜索
 */
export const articleSearchApi = (text: string, p = 1) => {
    return useFetchRefPost<ArticleVo>('articleSearchApi', '/article/list', {
        body: { title: text, pageNum: p }
    })
}
/**
 * 文章详情
 */
export const articleDetailsApi = (articleId: string) => {
    return useFetchRefGet<ArticleVo>(`articleDetails${articleId}`, `/article/details/${articleId}`)
}
/**
 * 最新文章列表
 */
export const articleNewApi = (p = 1) => {
    return useFetchRefPost<ArticleVo>('articleNewApi', '/article/list', {
        body: { isNew: 1, pageNum: p }
    })
}
/**
 * 文章详情
 */
export const articlePostApi = (articleId: string) => {
    return useFetchGet<ArticleVo>('articlePostApi', `/article/details/${articleId}`)
}